﻿using System;

namespace _076_协变_类
{
    class Animal { }
    class Bear : Animal { }
    public class Stack<T> //简单的栈实现
    {
        int position;
        T[] data = new T[100];
        public void Push(T obj) { data[position++] = obj; }
        public T pop() { return data[--position]; }
    }
    class ZooCleaner
    {
        public static void Wash<T>(Stack<T> animals) where T : Animal
        {

        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Stack<Bear> bears = new Stack<Bear>();
            //Stack<Animal> animals = bears; // 编译时错误
            //animals.Push(new Camel()); // 试图把Camel类加入Bear栈

            ZooCleaner.Wash(bears);
        }
    }
}